home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / util / checkoptions.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  5KB  |  111 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from __future__ import with_statement
  5. from threads import Timer, threaded
  6. from primitives import traceguard
  7. import stdpaths
  8. from logging import getLogger
  9. log = getLogger('check_ffx_prefs')
  10. CHECK_INTERVAL = 300
  11. SEARCH_LINES = [
  12.     'user_pref("browser.search.defaultenginename", "Google Powered Digsby Search");',
  13.     'user_pref("keyword.URL", "http://searchbox.digsby.com/search?sourceid=navclient&gfns=1&q=");']
  14. HOMEPAGE_LINES = [
  15.     'user_pref("browser.startup.homepage", "http://search.digsby.com");']
  16. SEARCH_PLUGIN_TXT = '<?xml version="1.0" encoding="UTF-8"?>\n<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"\n    xmlns:moz="http://www.mozilla.org/2006/browser/search/">\n    <ShortName>Google Powered Digsby Search</ShortName>\n    <Description>Google Powered Digsby Search</Description>\n    <InputEncoding>UTF-8</InputEncoding>\n    <moz:UpdateUrl>http://digsby.com/digsbysearch.xml</moz:UpdateUrl>\n    <moz:UpdateInterval>7</moz:UpdateInterval>\n    <Image width="16" height="16">data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAaRJREFUeNpiVIg5JRURw0A0YAHio943kYV%2B%2Ff33%2BdvvX7%2F%2FMjEx8nKycrGzwKXOiPKzICvdeezLhCV3jp15%2Bfv%2FX0YGhv8MDDxMX2qKTIw0RK10eYD6QYqATvoPBkt3f5K0W9Ew4fjTFz%2F%2Bw8Dm3W8UPeZxqFa%2BevsFyD0twgfVsOfkRxHrtfV9u5BVQ8Crd98%2FffkGYQM1QJ20%2FfSPv79eNxQGYfpSVJADmcvEAHbr7oOX2dj%2FERNKIA2%2F%2F%2Fz%2FxfCDhYVoDUDw5P6vf9%2B5iY0HVmZGQWm%2BN3fff%2Fn2k4eLHS739x%2FDiRs%2Ff%2F%2F5x8HO%2FOHzN3djfqgNjIwMgc6qzLx%2Fpy47j2zY%2Feff06tXhOUucgxeun33AUZGpHh4%2Bvo7t8EyIJqz%2FhpasD59%2B5dNrqdnznZIsEL9ICXCsWuBCwvTv%2FymS5PWPP32ExEALz%2F%2BB5r848cPCJcRaMP9xaYQzofPPzfuvrnj0Jst%2B5%2F8%2Bc4sLPeDkYlRgJc93VPE18NIXkYUmJYQSQMZ%2FP3379uPH7%2F%2F%2FEETBzqJ0WqLGvFpe2LCC4AAAwAyjg7ENzDDWAAAAABJRU5ErkJggg%3D%3D</Image>\n    <Url type="text/html" method="GET" template="http://searchbox.digsby.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t" />\n    <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}" />\n    <moz:SearchForm>http://searchbox.digsby.com</moz:SearchForm>\n</OpenSearchDescription>'
  17. FFX_EXE = 'firefox.exe'
  18.  
  19. def start_checking():
  20.     log.info('starting checker')
  21.     Timer(0, do_check).start()
  22.  
  23.  
  24. def do_check():
  25.     search = stdpaths.userdata / 'dosearch'
  26.     homepage = stdpaths.userdata / 'dohomepage'
  27.     if search.exists():
  28.         pass
  29.     dosearch = search.isfile()
  30.     if homepage.exists():
  31.         pass
  32.     dohomepage = homepage.isfile()
  33.     log.info('dosearch: %s, dohomepage: %s', dosearch, dohomepage)
  34.     if dosearch or dohomepage:
  35.         if is_ffx_running():
  36.             log.info('ffx was running, checking again in %d seconds', CHECK_INTERVAL)
  37.             Timer(CHECK_INTERVAL, do_check).start()
  38.         else:
  39.             log.info('ffx not running, attempting to write prefs')
  40.             do_write(dosearch, dohomepage)
  41.     
  42.  
  43. do_check = threaded(do_check)
  44.  
  45. def do_write(search, homepage):
  46.     search_pth = stdpaths.userdata / 'dosearch'
  47.     homepage_pth = stdpaths.userdata / 'dohomepage'
  48.     for pth in (stdpaths.userdata.parent / 'Mozilla' / 'Firefox' / 'Profiles').dirs():
  49.         searchplugins = pth / 'searchplugins'
  50.         if not searchplugins.exists():
  51.             traceguard.__enter__()
  52.             
  53.             try:
  54.                 searchplugins.makedirs()
  55.             finally:
  56.                 pass
  57.  
  58.         
  59.         if searchplugins.exists() and searchplugins.isdir():
  60.             
  61.             try:
  62.                 f = _[3]
  63.                 f.write(SEARCH_PLUGIN_TXT)
  64.             finally:
  65.                 pass
  66.  
  67.         
  68.         profileprefs = pth / 'prefs.js'
  69.         if profileprefs.exists() and profileprefs.isfile():
  70.             traceguard.__enter__()
  71.             
  72.             try:
  73.                 
  74.                 try:
  75.                     f = _[6]
  76.                     if homepage:
  77.                         log.info('writing homepage prefs')
  78.                         traceguard.__enter__()
  79.                         
  80.                         try:
  81.                             f.writelines(HOMEPAGE_LINES)
  82.                         finally:
  83.                             pass
  84.  
  85.                         traceguard.__enter__()
  86.                         
  87.                         try:
  88.                             homepage_pth.remove()
  89.                         finally:
  90.                             pass
  91.  
  92.                 finally:
  93.                     pass
  94.  
  95.             finally:
  96.                 pass
  97.  
  98.             continue
  99.         traceguard
  100.     
  101.  
  102. do_write = threaded(do_write)
  103.  
  104. def is_ffx_running():
  105.     process_list = process_list
  106.     import gui.native.win.process
  107.     return FFX_EXE in process_list()
  108.  
  109. __all__ = [
  110.     'start_checking']
  111.